clear
set type double
set more 1

capture log using log/TableA6.log, replace
*produces Table A6 
*share_other: note that 70% obs are 0/1 (euro or noneuro) only 8.3% of obs are between 0.2 and 0.8
*The fractional ones that are greater than 0.2 and less than 0.8 only account for 8.3% of obs in erpt regs

use ../data/xcurrencychoice_estdata, clear
*need sum stats for Ix phi phiE phiX lnL marketshare iota plus IV instruments
estpost summarize Ix mphi_xeu mphi_xeu_euro mphi_xeu_other lnmemp ms mshcompetitor_other IVsh_US IVsh_CHN IVsh_other, detail

esttab using "../results/sumstats/TableA6.csv", cells("mean sd p5 p50 p95 count") title("xcurrency_choice") noobs nomtitles nonum replace
eststo clear


*sum stats for vehicle currency
use ../data/xcurrencychoice_estdata, clear
*need sum stats for I_D
*generate new Ix
*merging on mean competitor currency over sample period

drop Ix hs4
	gen hs4=substr(cncode,1,4)
	merge 1:1 vat cncode cty_code year month using ../dofiles_regressions/temp/vehicle_Ix, keep(match) nogen
	merge m:1 vat cty_code hs4 using ../data/mcompetitor_xcurrency_dollar, keep(match master) nogen

	rename Ix Id

estpost summarize Id , detail

esttab using "../results/sumstats/TableA6.csv", cells("mean sd p5 p50 p95 count") title("vcurrency_choice") noobs nomtitles nonum append
eststo clear


use ../data/erpt_annual_estdata, clear
	merge m:1 vat cty_code using ../data/currency_vehicle, keep(match master) nogen	
	drop if vehicle_other==1

*need sum stats for dp* de deD de*phi de*phiE de*phiE de*phiX de*S de*L de*ioata
estpost summarize duv_k dxE dxE_phi dxE_phi_euro dxE_phi_other dxE_ms_y dxE_lnmemp dxE_share_other share_other dxD, detail


gen dum=share_other>0.01 & share_other<0.99
gen dum20= share_other>0.2 & share_other<0.8
tab dum
tab dum20
 
esttab using "../results/sumstats/TableA6.csv", cells("mean sd p5 p50 p95 count") title("erpt") noobs nomtitles nonum append
eststo clear




log close

